package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TBack;
import com.ruoyi.system.service.ITBackService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 退舍管理Controller
 * 
 * @author fyk
 * @date 2024-05-09
 */
@RestController
@RequestMapping("/system/back")
public class TBackController extends BaseController
{
    @Autowired
    private ITBackService tBackService;

    /**
     * 查询退舍管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:back:list')")
    @GetMapping("/list")
    public TableDataInfo list(TBack tBack)
    {
        startPage();
        List<TBack> list = tBackService.selectTBackList(tBack);
        return getDataTable(list);
    }

    /**
     * 导出退舍管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:back:export')")
    @Log(title = "退舍管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TBack tBack)
    {
        List<TBack> list = tBackService.selectTBackList(tBack);
        ExcelUtil<TBack> util = new ExcelUtil<TBack>(TBack.class);
        util.exportExcel(response, list, "退舍管理数据");
    }

    /**
     * 获取退舍管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:back:query')")
    @GetMapping(value = "/{BuildBackId}")
    public AjaxResult getInfo(@PathVariable("BuildBackId") Integer BuildBackId)
    {
        return success(tBackService.selectTBackByBuildBackId(BuildBackId));
    }

    /**
     * 新增退舍管理
     */
    @PreAuthorize("@ss.hasPermi('system:back:add')")
    @Log(title = "退舍管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TBack tBack)
    {
        return toAjax(tBackService.insertTBack(tBack));
    }

    /**
     * 修改退舍管理
     */
    @PreAuthorize("@ss.hasPermi('system:back:edit')")
    @Log(title = "退舍管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TBack tBack)
    {
        return toAjax(tBackService.updateTBack(tBack));
    }

    /**
     * 删除退舍管理
     */
    @PreAuthorize("@ss.hasPermi('system:back:remove')")
    @Log(title = "退舍管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{BuildBackIds}")
    public AjaxResult remove(@PathVariable Integer[] BuildBackIds)
    {
        return toAjax(tBackService.deleteTBackByBuildBackIds(BuildBackIds));
    }
}
